<?php
    $user       = API::userLoad();
    $timezones  = API::timeZoneGetList();
?>

<div class="form-group">
    <label for="account-input-email">
        Email
    </label>
    <?php
        FT::email("email",arrGet($user,"email"),array(
            "class"     => "form-control",
            "id"        => "account-input-email",
            "maxlength" => 255
        ));
    ?>
</div>

<div class="form-group">
    <label for="account-input-firstname">
        Firstname
    </label>
    <?php
        FT::input("firstname",arrGet($user,"firstname"),array(
            "class"     => "form-control",
            "id"        => "account-input-firstname",
            "maxlength" => 50
        ));
    ?>
</div>

<div class="form-group">
    <label for="account-input-lastname">
        Lastname
    </label>
    <?php
        FT::input("lastname",arrGet($user,"lastname"),array(
            "class"     => "form-control",
            "id"        => "account-input-lastname",
            "maxlength" => 50
        ));
    ?>
</div>

<div class="form-group">
    <label for="account-select-timezone">
        Timezone
    </label>
    <?php
        FT::select("timezoneid",$timezones,array(
            "class" => "form-control",
            "id"    => "account-select-timezone"
        ),null,arrGet($user,"timezoneid"));
    ?>
</div>

<div class="form-group">
    <label for="account-select-timeout">
        Timeout (min)
    </label>
    <?php
        $timeouts = array(
            30  => 30,
            60  => 60,
            120 => 120,
            240 => 240,
            360 => 360
        );
        FT::select("timeout_min",$timeouts,array(
            "class" => "form-control",
            "id"    => "account-select-timeout"
        ),null,arrGet($user,"timeout_min"));
    ?>
</div>

<div class="form-group">
    <strong>Unit</strong>&nbsp;
    <label class="radio-inline">
        <?php
            FT::radio("default_unit","kg",null,arrGet($user,"default_unit"));
        ?>
        KG
    </label>
    <label class="radio-inline">
        <?php
            FT::radio("default_unit","lb",null,arrGet($user,"default_unit"));
        ?>
        LB
    </label>
</div>

<div class="form-group">
    <label for="account-input-password">
        New password
    </label>
    <?php
        FT::password("password",null,array(
            "class"     => "form-control",
            "id"        => "account-input-password",
            "maxlength" => 255
        ));
    ?>
</div>

<div class="form-group">
    <label for="account-input-password2">
        Confirm password
    </label>
    <?php
        FT::password("password2",null,array(
            "class"     => "form-control",
            "id"        => "account-input-password2",
            "maxlength" => 255
        ));
    ?>
</div>

<?php
    FT::button("Save",array(
        "class"             => "button-submitform btn btn-default",
        "data-classname"    => "User",
        "data-functionname" => "save"
    ));
?>

<script type="text/javascript">
    $("#account-input-email").focus();
    
    __APICALL_FUNC["User/save"] = function(result) {
        var override = null;
        if (result.code == 0) {
            override = "Account data saved!"
        }
        setError.call(this,result,override);
    }
</script>